from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render, redirect


def index(request):
    return HttpResponse('<h1>Hello World</h1>')


def test(request):
    hi = '你好，世界是美丽的'
    test = "这是一个测试页，动态页面正常显示，测试成功"
    return render(request, 'test.html', {'hi':hi, 'test':test})


def login(request):
    if request.method == 'GET':
        return render(request, 'login.html')
    else:
        username = request.POST.get('username')
        password = request.POST.get('password')
        if username == 'test' and password == '123':
            return redirect('/test/')
        else:
            return render(request, 'login.html', {'error': '用户名或密码错误'})